/**************************************************************************/
/*                                                                        */
/* Copyright (c) SinoEmbed Technology Co.,Ltd.           */
/*  */
/*                                                                        */
/*                                                                        */
/*    created:    2012-6-27                                             */ 
/*    filename:   SinoembedPuzzleApp.cpp                                          */ 
/*    author:     Derek Huang                                                  */  
/*    purpose:                                                            */ 
/*                                                                        */
/* ************************************************************************/
#include "SinoembedBlueToothApp.h"

CSinoembedBlueToothApp theApp;
#define WM_SOURCE_SHOWWINDOW (WM_USER + 251)

CSinoembedBlueToothApp::CSinoembedBlueToothApp()
{
	m_pMainWin = NULL;
}
CSinoembedBlueToothApp::~CSinoembedBlueToothApp()
{
	CoUninitialize();	
}
BOOL CSinoembedBlueToothApp::Init()
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED );
	HANDLE Handle = CreateMutex(NULL,FALSE,L"SinoembedBlueTooth");
	if (GetLastError() != ERROR_ALREADY_EXISTS)
	{
		int cx,cy;
		cx = GetSystemMetrics(SM_CXSCREEN);
		cy = GetSystemMetrics(SM_CYSCREEN);
		m_pMainWin = new CSinoembedBlueToothWnd();
		if( m_pMainWin )
		{
			if(m_pMainWin->Create(0, 0, cx, cy, 0, 0, 0, 0))
			{
				m_pMainWin->Show();
				return TRUE;
			}
			else
			{
				return FALSE;
			}	
		}
		else
		{
			return FALSE;
		}

		return CMzApp::Init();
	}
	else
	{
		HWND hFileBrowserWnd = ::FindWindow(NULL, L"CSinoembedBlueToothWnd");
		::SendMessage(hFileBrowserWnd, WM_SOURCE_SHOWWINDOW, (WPARAM)1, 0);

	}	
	return 0;
	
	
}
